package com.charles.bigdata.mapreduce.order;

import java.io.IOException;

import org.apache.hadoop.io.DoubleWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

// 泛型 k1 v1 k2 v2四个数据的类型
public class OrderMapper extends Mapper<LongWritable, Text, OrderBean, NullWritable> {
	OrderBean bean = new OrderBean();

	@Override
	protected void map(LongWritable key1, Text value1, Context context) throws IOException, InterruptedException {

		String line = value1.toString();

		String[] fields = line.split(",");

		bean.set(new Text(fields[0]), new DoubleWritable(Double.parseDouble(fields[2])));

		// 输出 k2    v2
		context.write(bean, NullWritable.get());
	}

}